package com.example.demo.controller;

import com.example.demo.entity.Dept;
import com.example.demo.entity.R;
import com.example.demo.service.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author CDHong
 * @since 2024-10-17 08:59
 */
@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private IDeptService deptService;

    @GetMapping("/list")
    public R list(){
        List<Dept> list = deptService.list();
        return R.data(list);
    }

    @PutMapping("/save")
    public R save(Dept dept){
        boolean flg = deptService.save(dept);
        if(flg){
            return R.ok("添加成功！");
        }else{
            return R.error("添加失败！");
        }
    }




}
